/*
 * Copyright Hundsun Technologies Inc. All Rights Reserved.
 */

package config

// CommonConfig 节点启动需要传入的配置
type CommonConfig struct {
	ConsoleConfig       *ConsoleConfig       `yaml:"console"`
	EtcdConfig          *EtcdConfig          `yaml:"etcd"`
	ElasticSearchConfig *ElasticSearchConfig `yaml:"elasticSearch"`
	RedisConfig         *RedisConfig         `yaml:"redis"`
}

// ConsoleConfig 节点内置控台配置
type ConsoleConfig struct {
	InternalIP string `yaml:"internalIP"`
	Port       int    `yaml:"port"`
	Username   string `yaml:"username"`
	Password   string `yaml:"password"`
}

// EtcdConfig ETCD配置参数，参数含义同官方客户端go.etcd.io/etcd模块的clientv3.Config
type EtcdConfig struct {
	Endpoints                  []string `yaml:"endpoints"`
	Username                   string   `yaml:"username"`
	Password                   string   `yaml:"password"`
	DialTimeoutMillis          int      `yaml:"dialTimeoutMillis"`
	DialKeepAliveTimeMillis    int      `yaml:"dialKeepAliveTimeMillis"`
	DialKeepAliveTimeoutMillis int      `yaml:"dialKeepAliveTimeoutMillis"`
	MaxCallSendMsgSizeKB       int      `yaml:"maxCallSendMsgSizeKB"`
	MaxCallRecvMsgSizeKB       int      `yaml:"maxCallRecvMsgSizeKB"`
}

// ElasticSearchConfig ElasticSearch配置参数
type ElasticSearchConfig struct {
	Addresses  []string `yaml:"addresses"`
	Username   string   `yaml:"username"`
	Password   string   `yaml:"password"`
	MaxRetries int      `yaml:"maxRetries"`
	Sniff      bool     `yaml:"sniff"`
}

// RedisConfig Redis配置参数
type RedisConfig struct {
	Address                  string `yaml:"address"`
	Auth                     string `yaml:"auth"`
	DB                       string `yaml:"db"`
	MaxIdle                  int    `yaml:"maxIdle"`
	MaxActive                int    `yaml:"maxActive"`
	IdleTimeoutMillis        int    `yaml:"idleTimeoutMillis"`
	DialConnectTimeoutMillis int    `yaml:"dialConnectTimeoutMillis"`
	DialReadTimeoutMillis    int    `yaml:"dialReadTimeoutMillis"`
	DialWriteTimeoutMillis   int    `yaml:"dialWriteTimeoutMillis"`
}

// PluginConfig 可插拔插件配置
type PluginConfig struct {
	Name       string            `yaml:"name"`
	Parameters map[string]string `yaml:"parameters"`
}

// PluginConfigs 同一种类下的插件
type PluginConfigs struct {
	Plugins []*PluginConfig `yaml:"plugins"`
}
